package com.example.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.alibaba.druid.pool.DruidDataSource;

@Configuration
public class ConnctConfig {

	@Bean
	public DruidDataSource druidDataSource() {
		// Druid 数据源配置
		DruidDataSource dataSource = new DruidDataSource();
		dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
		dataSource.setUrl("jdbc:mysql://192.168.138.128/test?characterEncoding=utf8");
		dataSource.setUsername("root");
		dataSource.setPassword("mysql");
		// 初始连接数(默认值0)
		dataSource.setInitialSize(8);
		// 最小连接数(默认值0)
		dataSource.setMinIdle(8);
		// 最大连接数(默认值8,注意"maxIdle"这个属性已经弃用)
		dataSource.setMaxActive(32);
		return dataSource;
	}
}
